import Vue from 'vue'
import Router from 'vue-router'
// 导入组件
import AppIndex from '@/components/AppIndex'
import Login from '@/components/Login'

import MainPage from "../components/MainPage";
import PurchaseControl from "../components/func/PurchaseControl";
import Purchase from "../components/func/purchase_manager/Purchase";
import GoodsManagement from "../components/func/GoodsManagement";
import Setting from "../components/func/Setting";
import KindsManage from "../components/func/setting/KindsManage";
import UnitsManage from "../components/func/setting/UnitsManage";
import Inventory from "../components/func/Inventory";
import Receipt from "../components/func/purchase_manager/Receipt";
import ReceiptDetail from "../components/func/purchase_manager/ReceiptDetail";
import CashierDesk from "../components/CashierSystem/CashierDesk";
import SaleManager from "../components/func/SaleManager";
import SupplierManage from "../components/func/setting/SupplierManage";
import Produce from "../components/func/sale_manage/Produce";
import VIPManage from "../components/func/setting/VIPManage";
import PersonalSpace from "../components/personalSpace/PersonalSpace";
import Employees from "../components/func/setting/employees/Employees";
import ActivityList from "../components/func/sale_manage/ActivityList";
import Statement from "../components/func/Statement";
import SaleReport from "../components/func/statement/components/SaleReport";
import Theme from "../components/func/setting/Theme";

Vue.use(Router)
// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
export default new Router({
  //使用history模式
  mode:'history',
  routes: [
    //入口页（注册与登录页）
    {
      path: '/login',
      name: 'Login',
      component: Login
    },
    {
      path:"",
      redirect: '/index'
    },
    {
      path: '/index',
      name: 'AppIndex',
      component: AppIndex,
      // index页面也并不需要被访问,用于承载公共组件以及子组件页面
      redirect: '/mainpage',
      meta:{
        requireAuth: true,
      },
      children: [
        {
          path:"",
          component: MainPage,
          meta:{
            requireAuth: true,
          },
        },
        {
          //首页
          path: '/mainpage',
          name: 'MainPage',
          component: GoodsManagement,
          meta:{
            //需要被拦截的页面
            requireAuth:true
          }
          },
        {
          //销售管理页
          path:'/salesManagement',
          name:'SalesManagement',
          component: SaleManager,
          meta:{
            requireAuth: true
          }
        },
        {
          //生产页
          path:'/salesManagement/produce',
          name:'Produce',
          component: Produce,
          meta:{
            requireAuth: true
          }
        },
        {
          //活动列表页
          path:'/salesManagement/activityList',
          name:'ActivityList',
          component:ActivityList,
          meta:{
            requireAuth: true,
          }
        },
        {//进货管理功能页
          path: '/purchaseControl',
          name: 'PurchaseControl',
          component: PurchaseControl,
          meta:{
            //需要被拦截的页面
            requireAuth:true
          }
          },
        {//商品管理功能页
          path: '/goodsManagement',
          name: 'GoodsManagement',
          component: GoodsManagement,
          meta:{
            //需要被拦截的页面
            requireAuth:true
          }
          },
        {//库存管理功能页
          path:'/inventoryManagement',
          name: 'InventoryManagement',
          component: Inventory,
          meta:{
            requireAuth: true
          }
        },
        {
          path:'/statementManagement',
          name:'StatementManagement',
          component:Statement,
          meta:{
            requireAuth: true,
          },
        },
        {
          path:'/statementManagement/saleReport',
          name:'SaleReport',
          component: SaleReport,
          meta: {
            requireAuth: true,
          }
        },
        {//系统设置功能页
          path: '/setting',
          name: 'Setting',
          component: Setting,
          meta:{
            //需要被拦截的页面
            requireAuth:true
          },
        },
        {
          path: '/setting/kindsManage',
          name: 'KindsManage',
          component: KindsManage,
          meta:{
            //需要被拦截的页面
            requireAuth:true
          }
        },
        {
          path: '/setting/unitsManage',
          name: 'UnitsManage',
          component: UnitsManage,
          meta:{
            //需要被拦截的页面
            requireAuth:true
          }
        },
        {
          path: '/setting/supplierManage',
          name: 'SupplierManage',
          component: SupplierManage,
          meta:{
            //需要被拦截的页面
            requireAuth:true
          }
        },
        {
          path: '/setting/VIPManage',
          name: 'VIPManage',
          component: VIPManage,
          meta:{
            //需要被拦截的页面
            requireAuth:true
          }
        },
        {
          path:'/setting/permissionsManage',
          name:'PermissionsManage',
          component: Employees,
          meta: {
            requireAuth: true,
          }
        },
        {
          path:'/setting/theme',
          name:'Theme',
          component:Theme,
          meta:{
            requireAuth: true,
          }
        },
        {//进货页
          path: '/purchase',
          name: 'Purchase',
          component: Purchase,
          meta:{
            //需要被拦截的页面
            requireAuth:true
          }
        },
        {
          //单据页
          path: '/receipt',
          name: 'Receipt',
          component: Receipt,
          meta: {
            requireAuth: true
          },
        },
        {
          path: '/receipt/receiptDetail',
          name: 'receiptDetail',
          component: ReceiptDetail,
          meta: {
            requireAuth: true
          }
          },
        ]
    },
    {
      path: '/cashierDesk',
      name: 'CashierDesk',
      component: CashierDesk,
      meta:{
        requireAuth:true
      }
    },
    {
      path:'/personalSpace',
      name:'PersonalSpace',
      component:PersonalSpace,
      meta:{
        requireAuth: true
      }
    },

  ]
})
